package com.woniuxy.service.impl;

import com.github.pagehelper.PageInfo;
import com.woniuxy.commons.utils.ResStatus;
import com.woniuxy.commons.utils.ResponseResult;
import com.woniuxy.dao.RegisteredOrderDao;
import com.woniuxy.entity.RegisteredOrder;
import com.woniuxy.service.RegisteredOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class RegisteredOrderServiceImpl implements RegisteredOrderService {
    @Resource
    RegisteredOrderDao registeredOrderDao;
    @Override
    public ResponseResult findAll(int currentPage, int pageSize) {

        List<RegisteredOrder> list = registeredOrderDao.findAll();
        PageInfo<RegisteredOrder> pageInfo = PageInfo.of(list);
        ResponseResult responseResult = new ResponseResult<>();

        responseResult.setData(pageInfo);

        responseResult.setCode(200);

        responseResult.setMsg("查询成功");

        responseResult.setStatus(ResStatus.SUCCESS);

        return responseResult;
    }

    @Override
    public ResponseResult search(RegisteredOrder registeredOrder) {
        List<RegisteredOrder> list=registeredOrderDao.search(registeredOrder);

        ResponseResult responseResult = new ResponseResult<>();

        responseResult.setCode(200);

        responseResult.setMsg("查询成功");

        responseResult.setStatus(ResStatus.SUCCESS);

        responseResult.setData(list);
        return responseResult;
    }

    @Override
    public ResponseResult findByStatus(int status) {
        List<RegisteredOrder> list=registeredOrderDao.findBystatus(status);

        ResponseResult responseResult = new ResponseResult<>();

        responseResult.setCode(200);

        responseResult.setMsg("查询成功");

        responseResult.setStatus(ResStatus.SUCCESS);

        responseResult.setData(list);
        return responseResult;
    }

    @Override
    public ResponseResult findByNo(String order_num) {
        RegisteredOrder registeredOrder=registeredOrderDao.findByNo(order_num);
        return new ResponseResult(200,"成功",registeredOrder,ResStatus.SUCCESS);
    }
}
